import java.awt.Graphics;
import java.awt.Point;

import javax.swing.JPanel;


public class GameMap {
	
	private String MapType;
	private Tile[][] map = new Tile[5][9];
	private MapPanel mapp;
	private NewGame game;
	
	/**
	 * creat a game map
	 * @param MT the input map type
	 * @param g  the new game
	 * */
	public GameMap(String MT, NewGame g){
		game = g;
		MapType = MT;
		if("Standard".equals(MapType)){
			standardMap();
		}
		else if("Random".equals(MapType)){
			randomMap();		
		}
	}
	
	/**
	 * Creat a standar type map.
	 * */
	private void standardMap(){
		String[][] cmap = { {"P","P","M1","P","R","P","M3","P","P"},
							{"P","M1","P","P","R","P","P","P","M3"},
							{"M3","P","P","P","Town","P","P","P","M1"},
							{"P","M2","P","P","R","P","M2","P","P"},
							{"P","P","M2","P","R","P","P","P","M2"}};		
		
		for(int i = 0; i < 5; i ++){
			for(int j = 0; j < 9; j++){
				if(cmap[i][j].equals("P")) map[i][j] = new Plain(new Point(i, j));
				else if(cmap[i][j].equals("R")) map[i][j] = new River(new Point(i,j));
				else if(cmap[i][j].equals("M1")) map[i][j] = new M1(new Point(i,j));
				else if(cmap[i][j].equals("M2")) map[i][j] = new M2(new Point(i,j));
				else if(cmap[i][j].equals("M3")) map[i][j] = new M3(new Point(i,j));
				else if(cmap[i][j].equals("Town")) map[i][j] = new TownTile(new Point(i,j));
				}
		}
		mapp = new MapPanel(map, game);
		
	}
	
	/**
	 * @return return a game panle
	 * */
	public MapPanel getPanel(){
		return mapp;
	}
	
	/**
	 * @return return whole map with tiles
	 * */
	public Tile[][] getTiles(){
		return map;
	}
	
	/**
	 * Building a random game map.
	 * */
	private void randomMap(){
		
	}
	
	
	
	
}
